package constructor;

public class Demo3 {
    public static void main(String[] args) {
        Phone p = new Phone();
        p.setBrand("iphone");
        p.setPrice(5000);
        p.show();
    }
}

/*
手机类：
    成员变量：
        品牌brand，价格price
    构造方法
        无参，有参
     成员方法：
        setXxx和getXxx
        show

 */
class Phone {
    private String brand;
    private int price;

    public Phone() {

    }

    public Phone(String brand,int price) {
        this.brand = brand;
        this.price = price;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getBrand() {
        return brand;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getPrice() {
        return this.price;//this.可以不加，系统会默认加上
    }
    public void show() {
        System.out.println(brand+"..."+price);
    }
}

